package com.pond.pond.controller;

import com.pond.common.core.web.controller.BaseController;
import com.pond.common.core.web.domain.AjaxResult;
import com.pond.common.core.web.page.TableDataInfo;
import com.pond.common.log.annotation.Log;
import com.pond.common.log.enums.BusinessType;
import com.pond.common.security.annotation.RequiresPermissions;
import com.pond.pond.domain.FishingTechniqueComment;
import com.pond.pond.service.IFishingTechniqueCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 钓技文章评论管理Controller
 * 
 * @author pond
 * @date 2024-01-15
 */
@RestController
@RequestMapping("/fishing/comment")
public class FishingTechniqueCommentController extends BaseController
{
    @Autowired
    private IFishingTechniqueCommentService fishingTechniqueCommentService;

    /**
     * 查询钓技文章评论列表
     */
    @RequiresPermissions("fishing:comment:list")
    @GetMapping("/list")
    public TableDataInfo list(FishingTechniqueComment fishingTechniqueComment)
    {
        startPage();
        List<FishingTechniqueComment> list = fishingTechniqueCommentService.selectFishingTechniqueCommentList(fishingTechniqueComment);
        return getDataTable(list);
    }

    /**
     * 获取钓技文章评论详细信息
     */
    @RequiresPermissions("fishing:comment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishingTechniqueCommentService.selectFishingTechniqueCommentById(id));
    }

    /**
     * 删除钓技文章评论
     */
    @RequiresPermissions("fishing:comment:remove")
    @Log(title = "钓技文章评论", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishingTechniqueCommentService.deleteFishingTechniqueCommentByIds(ids));
    }

    /**
     * 修改评论状态
     */
    @RequiresPermissions("fishing:comment:edit")
    @Log(title = "钓技文章评论", businessType = BusinessType.UPDATE)
    @PutMapping("/{id}/status")
    public AjaxResult updateStatus(@PathVariable Long id, @RequestBody FishingTechniqueComment comment)
    {
        comment.setId(id);
        return toAjax(fishingTechniqueCommentService.updateFishingTechniqueComment(comment));
    }

    /**
     * 回复评论
     */
    @RequiresPermissions("fishing:comment:edit")
    @Log(title = "钓技文章评论", businessType = BusinessType.INSERT)
    @PostMapping("/reply")
    public AjaxResult reply(@RequestBody FishingTechniqueComment comment)
    {
        return toAjax(fishingTechniqueCommentService.insertFishingTechniqueComment(comment));
    }
}